package org.procrastinationapp;

import com.ibm.icu.util.Calendar;

public class Singleton implements Runnable {
	public static final String A_STRING = "Hello World".toLowerCase();
	
	public static final String ANOTHER_STRING = "Hello World".concat(String.valueOf(Calendar.getInstance().getTimeInMillis()));

	public static final Singleton INSTANCE = new Singleton();

	public static Singleton getInstance() {
		return INSTANCE;
	}

	private Singleton() {
		super();
		launchThread();
	}

	public void launchThread() {
		synchronized (this) {
			Thread t = new Thread(this);
			t.start();
			while (t.isAlive()) {
				try {
					System.out.println("Waiting...");
					System.out.println(ANOTHER_STRING);
					wait(100);
				} catch (InterruptedException e) {
					// Interrupted.
				}
			}
		}
	}

	public void run() {
		System.out.println("I'm going to write...");
		System.out.println(ANOTHER_STRING);
		System.out.println(A_STRING);
	}

	public static void main(String[] args) {
		Singleton.getInstance();
	}
}
